<?php 
defined('IN_TS') or die('Access Denied.');

switch($ts){

	case "list":
	
		$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
		$url = SITE_URL.'index.php?app=ask&ac=admin&mg=topic&ts=list&page=';
		$lstart = $page*20-20;

		$topicNum = $new['ask']->findCount('ask_topic');
		$pageUrl = pagination($topicNum, 20, $page, $url);
	
		$arrTopic = $new['ask']->findAll('ask_topic',null,'addtime desc',null,$lstart.',20');
		
		include template('admin/topic_list');
	
		break;
		
	//删除
	case "delete":
	
		$askid = intval($_GET['askid']);
		
		$new['ask']->delete('ask_topic',array(
			'askid'=>$askid,
		));
		
		$new['ask']->delete('ask_comment',array(
			'askid'=>$askid,
		));
		
		$new['ask']->delete('ask_question_add',array(
			'askid'=>$askid,
		));
		
		$new['ask']->delete('ask_topic_cate',array(
			'askid'=>$askid,
		));
		
		
		qiMsg('删除成功！');
	
		break;
		
	//审核 
	case "isaudit":
		
		$askid = intval($_GET['askid']);
		
		$strAsk = $new['ask']->find('ask_topic',array(
		
			'askid'=>$askid,
		
		));
		
		if($strAsk['isaudit']==0){
		
			$new['ask']->update('ask_topic',array(
				'askid'=>$askid,
			),array(
				'isaudit'=>1,
			));
		
		}
		
		if($strAsk['isaudit']==1){
		
			$new['ask']->update('ask_topic',array(
				'askid'=>$askid,
			),array(
				'isaudit'=>0,
			));
		
		}
		
		qiMsg('操作成功！');
		
		break;

}